package com.five.matebook.utils;

import android.content.Context;
import android.util.Log;

import com.tencent.mmkv.MMKV;

public class MmkvUtils {
    private static final String TAG = MmkvUtils.class.getSimpleName();
    private static volatile boolean mInitialed = false;
    private static MMKV getMmkv(Context context) {
        synchronized (MmkvUtils.class) {
            if (!mInitialed) {
                mInitialed = true;
                String rootDir = MMKV.initialize(context.getApplicationContext());
                Log.d(TAG, "rootDir is " + rootDir);
            }
        }
        return MMKV.defaultMMKV();
    }

    public static void saveString(Context context, String key, String value) {
        getMmkv(context).putString(key, value);
    }

    public static String getString(Context context, String key) {
        return getMmkv(context).getString(key, null);
    }
}
